import Statistical from './Statistical';
import StatisticalCard from './Statistical/Card';
import StatisticalLeft from './Statistical/Left';
import Dialog from './Dialog';
import Upload from './Upload';
import DialogRemove from './Dialog/Remove';
import Page from './Page';
import Search from './Page/Search';
import Back from './Back';
import CountDown from './Conuntdown';
import Tab from './Tab';

import Province from './Province';

import Steps from './Steps';

import Map from './Map';
export default {
	install(app) {
		app.component('LStatistical', Statistical);
		app.component('LStatisticalCard', StatisticalCard);
		app.component('LDialog', Dialog);
		app.component('LSearch', Search);
		app.component('LDialogRemove', DialogRemove);
		app.component('LUploadImage', Upload);
		app.component('LPage', Page);
		app.component('LBack', Back);
		app.component('LCountDown', CountDown);
		app.component('LStatisticalLeft', StatisticalLeft);
		app.component('LTab', Tab);
		app.component('LProvince', Province);
		app.component('LSteps', Steps);
		app.component('LMap', Map);
		const lDialogRemove = app.extend(DialogRemove);
		app.dialogRemove = app.prototype.$dialogRemove = function (title = null) {
			const dialogRemove = new lDialogRemove();
			if (!dialogRemove.$el) {
				let vm = dialogRemove.$mount();
				document.querySelector('body').appendChild(vm.$el);
			}
			dialogRemove.title = title;
			dialogRemove.show();
			return new Promise((resolve, reject) => {
				dialogRemove.ok = () => {
					dialogRemove.loading(true);
					setTimeout(() => {
						resolve({
							hide: dialogRemove.hide,
							loading: dialogRemove.loading,
						});
					}, 100);
				};
				dialogRemove.close = () => {
					dialogRemove.loading(false);
					reject({
						hide: dialogRemove.hide,
						loading: dialogRemove.loading,
					});
				};
			});
		};
	},
};
